package com.example.orderform.contorller;


import com.example.orderform.server.PaymentServer;
import com.example.orderform.vo.Order;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

@Api
public class PaymentContorller {
  @Autowired
    PaymentServer paymentServer;

  @ApiOperation("待付款条数查询接口")
  @RequestMapping("/taiocha")

  public int taiocha(
          @RequestParam(value = "userid",required = false)int userid){
    return  paymentServer.paycha(userid);
  }

@ApiOperation("待付款查")
  @RequestMapping("/fenyecha")

  public List<Order>fenyecha( @RequestParam("q") int q,
                              @RequestParam("j") int j,
                              @RequestParam("userid")int userid){
       List<Order> orderList = paymentServer.fenyecha(q, j,userid);
    if (orderList!=null){
      return orderList;
    }
return null;
  }
@ApiOperation("带付款页面详情")
  @RequestMapping("/payorderxq")

  public Order payorderxq(@RequestParam("orderid")int orderid){
    Order order=paymentServer.payorderxq(orderid);
    return order;
  }

  @ApiOperation("取消商品")
  @ApiImplicitParam(name = "orderid",value = "交易码")
  @RequestMapping("/qx")
  public int qx(@RequestParam("orderid")String orderid,
                @RequestParam("cancel")String cancel){

    if (orderid!=null){

      int xx=paymentServer.qx(orderid,cancel);
      return xx;
    }
    return 0;
  }



  @ApiOperation("倒计时")
  @RequestMapping("/djs")
  public String djs(@RequestParam("orderid")int orderid){
    String djs=paymentServer.djs(orderid);
    return djs;

  }

  @ApiOperation("交易关闭")
  @RequestMapping("/gb")
  public int gb(@RequestParam("orderid")int orderid) {


    int gb = paymentServer.gb(orderid);
    return gb;
  }




  @RequestMapping("/chams")
  public String chams(
          @RequestParam("orderid") int orderid
  ){
    return  paymentServer.comitydescription(orderid);
  }




  @RequestMapping("/updatedd")
  public int updatedd(
          @RequestParam("ordernumber") String ordernumber
  ){

    paymentServer.updatedd(ordernumber);

    return 1;
  }

}
